package com.bjwl.service.impl;

import com.bjwl.dao.PartmentMapper;
import com.bjwl.pojo.Partment;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.PartmentService;
import com.bjwl.utils.Log4jUtils;
import com.bjwl.utils.PageBean;
import com.bjwl.web.intereptor.AdminLoginInterceptor;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/6 9:38
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class PartmentServiceImpl implements PartmentService {

    @Autowired
    private PartmentMapper partmentMapper;

    @Override
    public boolean addPartment(Partment partment) {
            partmentMapper.addPartment(partment);
            return true;

    }

    @Override
    public PageBean<Partment> findAllPartment(BasicQueryVo vo) {
        PageBean<Partment> pageBean = new PageBean<Partment>(vo.getPageNum(),10,partmentMapper.getTotalRecord(vo));
        pageBean.setData(partmentMapper.findAllPartment(pageBean,vo));
        return pageBean;
    }


    @Override
    public Partment editStart(Integer pmid) {
        return partmentMapper.findPartmentById(pmid);
    }

    @Override
    public boolean updatePartment(Partment partment) {
        Integer state = partmentMapper.updatePartment(partment);
        if(state > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deletePartment(Integer pmid) {
        try {
            partmentMapper.deletePartment(pmid);
        }catch (Exception e){
            Log4jUtils.LITERAL3.getLog().error(e.getMessage());
        }
        return true;
    }


}
